package com.lxw.oa.util;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * Created by Administrator on 2019/4/24.
 */
public class ImpalaJdbc2 {
    static String JDBC_DRIVER = "com.cloudera.impala.jdbc41.Driver";
    static String CONNECTION_URL = "jdbc:impala://192.168.5.70:21050/default;AuthMech=3;UID=root;PWD=;UseSasl=0";
    public static void main(String[] args){
        Connection con = null;
        ResultSet rs = null;
        PreparedStatement ps = null;
        try{
            Class.forName(JDBC_DRIVER);
            con = DriverManager.getConnection(CONNECTION_URL,"","");
            ps = con.prepareStatement("SELECT c.name, m.* FROM foundation.api_method m , foundation.api_category c where m.category_id=c.id");
            rs = ps.executeQuery();
            while (rs.next()){
                System.out.println(rs.getString(1));
            }
        } catch (Exception e){
            e.printStackTrace();
        } finally{
            try {
                ps.close();
                rs.close();
                con.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
